package com.gtm.model;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import org.springframework.data.mongodb.core.mapping.Document;

import javax.persistence.Id;

/**
 * Created by dell on 2017/10/25.
 */
@Document(collection = "user")
public class User {
    @Id
    private String id;//主键 用于mongodb的"_id"索引
    private String username;//登陆名
    private String passwd;//密码 md5 并不安全
    private String realname;//真实姓名
    private byte type;//用户类型  分为学生0 导师1 系主任2 教务办3
    private DBObject detail;//用户详细信息 用于存放用户的电话号码 邮箱等
    private byte state;// 0 禁用  1 可用
    private String selectTopicState="pending";
    private String topicId;
    private DBObject additionalData;
    public DBObject getAdditionalData() {
        return additionalData;
    }

    public void setAdditionalData(String key, Object value) {
        if(this.additionalData==null)
            this.additionalData=new BasicDBObject();
        this.additionalData.put(key,value);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public DBObject getDetail() {
        return detail;
    }

    public void setDetail(DBObject detail) {
        this.detail = detail;
    }

    public byte getState() {
        return state;
    }

    public void setState(byte state) {
        this.state = state;
    }

    public String getSelectTopicState() {
        return selectTopicState;
    }

    public void setSelectTopicState(String selectTopicState) {
        this.selectTopicState = selectTopicState;
    }

    public String getTopicId() {
        return topicId;
    }

    public void setTopicId(String topicId) {
        this.topicId = topicId;
    }

    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", username='" + username + '\'' +
                ", passwd='" + passwd + '\'' +
                ", realname='" + realname + '\'' +
                ", type=" + type +
                ", detail=" + detail +
                ", state=" + state +
                ", selectTopicState='" + selectTopicState + '\'' +
                ", topicId='" + topicId + '\'' +
                ", additionalData=" + additionalData +
                '}';
    }
}
